Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 30, 2025

Problem

The agent.tool.responseLength telemetry event was only reporting the size of tool outputs, missing crucial information about the size of tool inputs. This made it difficult to get a complete picture of token consumption and costs associated with tool invocations.

Solution

Modified the sendInvokedToolTelemetry function to calculate and report both input and output token counts:

  1. Added toolInput parameter to the function signature to accept the tool call input as a string
  2. Parallel token counting using Promise.all to efficiently calculate both:
    • tokenCount: Number of tokens in the tool response (output)
    • inputTokenCount: Number of tokens in the tool input
  3. Updated GDPR telemetry metadata to document the new inputTokenCount measurement field
  4. Updated all call sites to pass the tool input:
    • In toolCalling.tsx: Pass this.props.toolCall.arguments (already a JSON string)
    • In chatVariables.tsx: Serialize the input object with JSON.stringify(input)

Example

When a tool is invoked with input like:

{"param1": "value1", "param2": "value2"}

The telemetry event now includes:

  • toolName: Name of the tool being invoked
  • tokenCount: Token count of the tool's response
  • inputTokenCount: Token count of the tool's input (new)

This provides complete visibility into token consumption for both sides of tool invocations, enabling better cost tracking and optimization.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • iojs.org
    • Triggering command: curl -q --fail --compressed -L -s REDACTED -o - (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

The agent.tool.responseLength telemetry event should also report the size of the tool call input


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link
Contributor Author

Copilot AI commented Sep 30, 2025

@digitarald Unfortunately, I hit an error while trying to use the custom Copilot setup steps configured for this repository and had to close this PR. The error I am seeing is:

No `copilot-setup-steps` job found in your `copilot-setup-steps.yml` workflow file. Please ensure you have a single job named `copilot-setup-steps`. For more details, see https://gh.io/copilot/actions-setup-steps.

Once you or someone with the necessary access fixes the problem, please unassign and then reassign issue #0 to me and I'll retry. Thanks!

@Copilot Copilot AI changed the title [WIP] The agent.tool.responseLength telemetry event should also report the size of the tool call input Add input token count to agent.tool.responseLength telemetry event Sep 30, 2025
@Copilot Copilot AI requested a review from digitarald September 30, 2025 20:43
Copilot finished work on behalf of digitarald September 30, 2025 20:43
@digitarald digitarald assigned Copilot and unassigned Copilot Sep 30, 2025
@digitarald digitarald requested a review from isidorn September 30, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants